{% extends "base.html" %}
{% comment %}
Copyright 2010 Google Inc.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
{% endcomment %}

{% load i18n %}
{% block content %}
{% include "map.html" %}
<form method="post" enctype="multipart/form-data" action="/create">
  {{env.subdomain_field_html|safe}}
  <input type="hidden" name="role" value="{{params.role}}">
  <table class="create" cellpadding="0" cellspacing="0">
    <tr class="columns">
      <td>
        <table class="person column" cellpadding="0" cellspacing="0">
          <tr>
            <td>
              <h2>
                {% ifequal params.role "provide" %}
                  {% trans "Identify who you have information about" %}
                {% else %}
                  {% trans "Identify who you are looking for" %}
                {% endifequal %}
              </h2>
              <table class="person input" cellpadding="0" cellspacing="0">
                <tr>
                  <td class="name section">
                    <h3 class="mandatory">
                      {% trans "Name (required)" %}
                    </h3>
                    <div class="hint">
                      {% trans "What is this person's name?" %}
                    </div>
                    <table class="fields">
                      {% if env.use_family_name and env.family_name_first %}
                        <tr>
                          <td class="label">
                            <label for="last_name" class="mandatory">
                              {% trans "Family name" %}:
                            </label>
                          </td>
                          <td>
                            <input name="last_name" id="last_name" size="20"
                                value="{{params.last_name}}"
                                autocomplete="off">
                          </td>
                        </tr>
                      {% endif %}
                        <tr>
                          <td class="label">
                            <label for="first_name" class="mandatory">
                              {% if env.use_family_name %}
                                {% trans "Given name" %}:
                              {% else %}
                                {% trans "Name" %}:
                              {% endif %}
                            </label>
                          </td>
                          <td>
                            <input name="first_name" id="first_name" size="20"
                                value="{{params.first_name}}"
                                autocomplete="off">
                          </td>
                        </tr>
                      {% if env.use_family_name and not env.family_name_first %}
                        <tr>
                          <td class="label">
                            <label for="last_name" class="mandatory">
                              {% trans "Family name" %}:
                            </label>
                          </td>
                          <td>
                            <input name="last_name" id="last_name" size="20"
                                value="{{params.last_name}}"
                                autocomplete="off">
                          </td>
                        </tr>
                      {% endif %}
                    </table>
                  </td>
                </tr>
                <tr>
                  <td class="address section">
                    <h3>
                      {% trans "Home Address" %}
                    </h3>
                    <div class="hint">
                      {% trans "Where is this person from?" %}
                    </div>
                    <table class="fields">
                      <tr>
                        <td class="label">
                          <label for="home_street">
                            {% trans "Street name" %}:
                          </label>
                          <div class="hint">{% trans "Street name only, no number" %}</div>
                        </td>
                        <td>
                          <input name="home_street" id="home_street" size="20"
                              autocomplete="off">
                        </td>
                      </tr>
                      <tr>
                        <td class="label">
{% comment %}
# i18n: For Pakistan, translate this as "Neighborhood, village, or town"
# i18n: since cities usually refer to large metropolitan areas.  Villages
# i18n: and towns are usually associated with the nearby metropolitan area,
# i18n: thus it makes more sense at a separate level than "City".
{% endcomment %}
                          <label for="home_neighborhood">{% trans "Neighborhood" %}:</label>
                        </td>
                        <td>
                          <input name="home_neighborhood" id="home_neighborhood"
                              size="20" autocomplete="off">
                        </td>
                      </tr>
                      <tr>
                        <td class="label">
                          <label for="home_city">{% trans "City" %}:</label>
                        </td>
                        <td>
                          <input name="home_city" id="home_city"
                              size="20" autocomplete="off">
                        </td>
                      </tr>
                      <tr>
                        <td class="label">
                          <label for="home_state">
                            {% trans "Province or state" %}:
                          </label>
                        </td>
                        <td>
                          <input name="home_state" id="home_state" size="10"
                              autocomplete="off">
                        </td>
                      </tr>
                      {% if env.use_postal_code %}
                        <tr>
                          <td class="label">
                            <label for="home_postal_code">
                              {% trans "Postal or zip code" %}:
                            </label>
                          </td>
                          <td>
                            <input name="home_postal_code" id="home_postal_code"
                                size="10" autocomplete="off">
                          </td>
                        </tr>
                      {% endif %}
                      </table>
                    </td>
                  </tr>
                  <tr>
                    <td class="description section">
                      <h3><label for="description">
                        {% trans "Description" %}
                      </label></h3>
                      <div class="hint">
                        {% trans "Describe how to identify this person." %}
                      </div>
                      <table class="fields">
                        <tr>
                          <td>
                            <textarea name="description" id="description"
                              cols=40 rows=5></textarea>
                          </td>
                        </tr>
                      </table>
                    </td>
                  </tr>
                  <tr>
                    <td class="photo section">
                      <h3><label for="photo_url">
                          {% trans "Photo" %}
                      </label></h3>
                      <div class="hint">
                        {% trans "If you have a photo of this person, upload it or enter its URL address." %}
                      </div>
                      <table class="fields">
                        <tr onclick="document.getElementById('photo_url_radio').checked=true; update_image_input();">
                          <td class="radio">
                              <input id="photo_url_radio" type="radio" checked="checked" name="photo_input"/>
                          </td>
                          <td class="label">
                            {% trans "URL" %}:
                          </td>
                          <td>
                            <input name="photo_url" id="photo_url" size="30">
                          </td>
                        </tr>
                        <tr onclick="document.getElementById('photo_upload_radio').checked=true; update_image_input();">
                          {% comment %} This td can be removed if uploading needs to be disabled {% endcomment %}
                          <td class="radio">
                              <input id="photo_upload_radio" type="radio" name="photo_input"/>
                          </td>
                          <td class="label">
                            {% trans "Upload" %}:
                          </td>
                          <td>
                            <input id="photo_upload" type="file" name="photo" id="photo_upload" size="20" disabled="disabled">
                          </td>
                          {% comment %} see above comment {% endcomment %}
                        </tr>
                     </table>
                    </td>
                  </tr>
<!-- Expiry is not fully implemented yet; hide it from the UI for now. -->
                  <tr style="display: none">
                    <td class="expiry section">
                      <h3><label for="expiry_date">
                          {% trans "Expiry" %}
                      </label></h3>
                      <div class="hint">
                        {% trans "When should this record disappear?" %}
                      </div>
                      <table class="fields">
			<tr>
			  <td>
                            <select id="expiry_option" name="expiry_option" value="">
                              {% for duration in env.expiry_options %}
                              <option value="{{duration.value}}">
                                {{duration.text}}
			      </option>
			      {% endfor %}
                            </select>
			  </td>
			</tr>
		      </table>
		    </td>
                  </tr>
                  <tr>
                    <td class="source section">
                      <h3 class="mandatory">
                        {% trans "Source of this record (required)" %}
                      </h3>
                      <div class="hint">
                        {% trans "Where did this information come from?" %}
                      </div>
                      <table class="fields">
                        <tr>
                          <td class="instructions" colspan="2">
                            <div>
                              <input type="radio" name="clone" value="no"
                                  id="clone_no" checked="checked"
                                  onclick="update_clone()"
                                  onchange="update_clone()">
                              <label class="option" for="clone_no">
                                {% trans "This is a new record." %}
                              </label>
                            </div>
                            <div>
                              <input type="radio" name="clone" value="yes"
                                  id="clone_yes" onchange="update_clone()"
                                  onclick="update_clone()">
                              <label class="option" for="clone_yes">
                                {% trans "This record is copied from another source." %}
                              </label>
                            </div>
                          </td>
                        </tr>
                        <tr>
                          <td class="label">
                            <label for="author_name" class="mandatory"
                                id="author_name_original">
                              {% trans "Your name" %}:
                            </label>
                            <label for="author_name" class="mandatory"
                                id="author_name_clone" style="display: none">
                              {% trans "Original author's name" %}:
                            </label>
                          </td>
                          <td>
                            <input name="author_name" id="author_name" size="20">
                          </td>
                        </tr>
                        <tr>
                          <td class="label">
                            <label for="author_phone" id="author_phone_original">
                              {% trans "Your phone number" %}:
                            </label>
                            <label for="author_phone"
                                id="author_phone_clone" style="display: none">
                              {% trans "Author's phone number" %}:
                            </label>
                          </td>
                          <td>
                            <input name="author_phone" id="author_phone" size="20">
                          </td>
                        </tr>
                        <tr>
                          <td class="label">
                            <label for="author_email" id="author_email_original">
                              {% trans "Your e-mail address" %}:
                            </label>
                            <label for="author_email"
                                id="author_email_clone" style="display: none">
                              {% trans "Author's e-mail address" %}:
                            </label>
                          </td>
                          <td>
                            <input name="author_email" id="author_email" size="20">
                          </td>
                        </tr>
                      <tr id="source_url_row" style="display: none">
                        <td class="label">
                          <label for="source_url">
                            {% trans "URL of original record" %}:
                          </label>
                        </td>
                        <td>
                          <input name="source_url" id="source_url" />
                        </td>
                      </tr>
                      <tr id="source_date_row" style="display: none">
                        <td class="label">
                          <label for="source_date">
                            {% trans "Original posting date" %}:
                          </label>
                          <div class="hint">{% trans "Enter as YYYY-MM-DD" %}</div>
                        </td>
                        <td>
                          <input name="source_date" id="source_date" />
                        </td>
                      </tr>
                      <tr id="source_name_row" style="display: none">
                        <td class="label">
                          <label for="source_name">
                            {% trans "Original site name" %}:
                          </label>
                        </td>
                        <td>
                          <input name="source_name" id="source_name" />
                        </td>
                     </tr>
                       {% include "subscribe.html" %}
                     </table>
                    </td>
                  </tr>
                  {% ifnotequal params.role "provide" %}
                  <tr>
                    <td align=left class="submit">
                      <input type="submit"
                          value="{% trans "Save this record" %}"
                          onclick="return validate_fields()">
                      <div id="mandatory_field_missing"
                          class="mandatory" style="display: none">
                        {% trans "Please fill in all the required fields." %}
                      </div>
                      <div id="status_inconsistent_with_found"
                          class="mandatory" style="display: none">
                        {% trans "The status you selected indicates that you are this person.  If this is true, please also select 'Yes' to indicate that you have contacted this person." %}
                      </div>
                    </td>
                  </tr>
                  {% endifnotequal %}
              </table>
            </td>
          </tr>
        </table>
      </td>

      {% ifequal params.role "provide" %}
        <td>
          {% include "add_note.html" %}
        </td>
      {% endifequal %}
    </tr>
  </table>
</form>
{% endblock %}
